import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {Card, WingBlank, WhiteSpace} from 'antd-mobile'
import { withRouter } from 'react-router-dom'

@withRouter
class UserCard extends Component{
  static propTypes={
    userList:PropTypes.array.isRequired
  }
  handleClick(v){
    this.props.history.push(`/chat/${v._id}`)
  }
  render(){
    const userList = this.props.userList
    return(
      <WingBlank>
      {userList.map(d=>(
        d.avatar?(
          <Card 
              key={d._id} 
              onClick={()=>{this.handleClick(d)}}
          >
          <Card.Header
            title={d.user}
            thumb={require(`../img/${d.avatar}.png`)}
            extra={<span>{d.title}</span>}
          >
          </Card.Header>
          <Card.Body>
            {d.type=='boss'?<div>公司:{d.company}</div>:null}
            {d.desc}
            {d.type=='boss'?<div>薪资:{d.money}</div>:null}
          </Card.Body>
        </Card>):null
      ))}
    </WingBlank>
    )
  }
}

export default UserCard